//
//  SaveImageUtils.m
//  StudyChina
//
//  Created by 月 吴 on 15/10/30.
//  Copyright © 2015年 BeiJingYuntai. All rights reserved.
//

#import "SaveImageUtils.h"
#import "NSString+Path.h"
#import "IWxChatMgrChatDefs.h"

@implementation SaveImageUtils
//保存Im的图片
+ (NSString *)saveChatImage:(UIImage *)currentImage withName:(NSString *)imageName
{
    NSData *temp = UIImageJPEGRepresentation(currentImage, 0.5);

    NSString *localFilePathName = [NSString wbChatPathWithType:kChatMsgBody_Image];
    [NSString checkFileFolderPathExist:localFilePathName];
    
    localFilePathName = [NSString stringWithFormat:@"%@/%@",localFilePathName,imageName];
    [temp writeToFile:localFilePathName atomically:YES];
    return localFilePathName;
}
+ (NSString *) saveImage:(UIImage *)currentImage withName:(NSString *)imageName
{
    NSData *temp = UIImageJPEGRepresentation(currentImage, 0.5);
    // 获取沙盒目录 --
    NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
    // 将图片写入文件
    [temp writeToFile:fullPath atomically:YES];
    return fullPath;
}

+ (long long) fileSizeAtPath:(NSString*) filePath{
    NSFileManager* manager = [NSFileManager defaultManager];
    if ([manager fileExistsAtPath:filePath]){
        return [[manager attributesOfItemAtPath:filePath error:nil] fileSize];
    }
    return 0;
}


@end
